/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package MainClasses.Event;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
/**
 *
 * @author andrewcutler
 */
public class EventCheckPanel extends EventPanel{
    
    private JCheckBox box;
    
    public EventCheckPanel(final Event event)
    {
        super();
        if(!Event.checkable(event))
        {
            System.err.println("ERROR: Event " + event + " is not checkable");
            return;
        }
        setLabel(new JLabel(event.getName()));
        box = new JCheckBox();
        if(((CheckableEvent)event).isChecked())
            box.doClick();
        box.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e)
           {
               ((CheckableEvent)event).check();
           }
        });
        setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
        this.addLabelMouseListener(new EventPanelListener(event));
        add(box);
        add(getLabel());
        
    }
}
